package cn.gov.pbc.gd.credit.log.service.operate.impl;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.liu.jbase.PageListVo;
import com.liu.jbase.ResultVo;
import com.liu.tools.LogUtil;

import cn.gov.pbc.gd.credit.api.log.ILogOperateApi;
import cn.gov.pbc.gd.credit.common.constant.CodeConstant;
import cn.gov.pbc.gd.credit.log.service.operate.ILogOperateService;
import cn.gov.pbc.gd.credit.vo.log.LogOperateVo;

/**
 * @date 2017年5月14日
 * @time 下午10:07:44
 * @author liuxingmi
 * @desc 用户操作日志
 */
@Service
public class LogOperateServiceImpl implements ILogOperateService{

	private static Logger logger = LoggerFactory.getLogger(LogOperateServiceImpl.class);
	
	@Autowired
	private ILogOperateApi logOperateApi;
	
	@Override
	public ResultVo<PageListVo<LogOperateVo>> page(LogOperateVo vo, HttpServletRequest request) {
		
		//Query query = new Query(Criteria.where("operatorId").is(vo.getOperateIp()).and("cname").is("zcy1"));
		

		
		PageListVo<LogOperateVo> pageListVo = new PageListVo<>();
		pageListVo.setCurrPage(vo.getCurPage());
		pageListVo.setPageSize(vo.getPageSize());

		ResultVo<PageListVo<LogOperateVo>> resultVo = new ResultVo<>();
		resultVo.setCode(CodeConstant.SUCCESS);
		
		try {
			PageListVo<LogOperateVo> pageList = logOperateApi.getPage(vo, pageListVo);
			resultVo.setData(pageList);
		} catch (Exception e) {
			logger.error(LogUtil.msg("LogOperateServiceImpl:page", "查询操作日志分页异常"), e);
			resultVo.setCode(CodeConstant.EXCEPTION);			
		}
		
		return resultVo;
	}

	
}
